{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 126,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bachelor</th>\n",
       "      <th>gender</th>\n",
       "      <th>age</th>\n",
       "      <th>salary</th>\n",
       "      <th>purchased</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "      <td>1500</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>30</td>\n",
       "      <td>2500</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>32</td>\n",
       "      <td>1800</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>25</td>\n",
       "      <td>1700</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>27</td>\n",
       "      <td>1200</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>26</td>\n",
       "      <td>1000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>35</td>\n",
       "      <td>3500</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "      <td>2000</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "      <td>1800</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>21</td>\n",
       "      <td>1700</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>38</td>\n",
       "      <td>5000</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>20</td>\n",
       "      <td>1200</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    bachelor  gender  age  salary  purchased\n",
       "0          1       0   23    1500          0\n",
       "1          1       0   30    2500          1\n",
       "2          1       0   32    1800          1\n",
       "3          1       0   25    1700          0\n",
       "4          1       0   27    1200          0\n",
       "5          1       1   26    1000          0\n",
       "6          1       1   35    3500          1\n",
       "7          1       0   23    2000          1\n",
       "8          1       0   22    1800          1\n",
       "9          1       0   21    1700          0\n",
       "10         1       1   38    5000          1\n",
       "11         1       1   20    1200          0"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas\n",
    "from sklearn.feature_selection import VarianceThreshold\n",
    "df = pandas.read_csv('data/customer_behavior.csv')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\ProgramData\\Anaconda3\\lib\\site-packages\\pandas\\indexes\\base.py:1434: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 5 but corresponding boolean dimension is 4\n",
      "  result = getitem(key)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Index(['gender', 'age', 'salary'], dtype='object')"
      ]
     },
     "execution_count": 129,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X = df[['bachelor','gender', 'age', 'salary']]\n",
    "sel = VarianceThreshold()\n",
    "X_val = sel.fit_transform(X)\n",
    "#X_val\n",
    "#sel.get_support()\n",
    "names = df.columns[sel.get_support()]\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[    0.             0.             4.48447205  2766.66666667]\n"
     ]
    }
   ],
   "source": [
    "from sklearn.feature_selection import SelectKBest\n",
    "from sklearn.feature_selection import chi2\n",
    "X = df[['bachelor','gender', 'age', 'salary']]\n",
    "y = df['purchased'].values\n",
    "clf = SelectKBest(chi2, k=2)\n",
    "clf.fit(X,y)\n",
    "print(clf.scores_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[  23 1500]\n",
      " [  30 2500]\n",
      " [  32 1800]\n",
      " [  25 1700]\n",
      " [  27 1200]\n",
      " [  26 1000]\n",
      " [  35 3500]\n",
      " [  23 2000]\n",
      " [  22 1800]\n",
      " [  21 1700]\n",
      " [  38 5000]\n",
      " [  20 1200]]\n"
     ]
    }
   ],
   "source": [
    "X_new = clf.fit_transform(X,y)\n",
    "print(X_new)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[(0.83299999999999996, 'salary'), (0.66700000000000004, 'age'), (0.33300000000000002, 'gender')]\n"
     ]
    }
   ],
   "source": [
    "from sklearn.cross_validation import cross_val_score, ShuffleSplit\n",
    "import numpy as np\n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "from sklearn.cross_validation import cross_val_score\n",
    "clf = DecisionTreeClassifier(random_state=123)\n",
    "scores = []\n",
    "for i in range(X_val.shape[1]):\n",
    "    score = cross_val_score(clf, X_val[:, i:i+1], y, scoring=\"accuracy\",\n",
    "                              cv=ShuffleSplit(len(X_val), 3, .3))\n",
    "    scores.append((round(np.mean(score), 3), names[i]))\n",
    "print(sorted(scores, reverse=True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 1.,  1.,  1.])"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scores_chi2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "?RFE"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "salary 1\n",
      "age 2\n",
      "gender 3\n"
     ]
    }
   ],
   "source": [
    "from sklearn.feature_selection import RFE\n",
    "from sklearn.svm import SVC\n",
    "\n",
    "clf = SVC(kernel='linear')\n",
    "\n",
    "rfe = RFE(clf, n_features_to_select=1)\n",
    "rfe.fit(X_val,y)\n",
    "\n",
    "for x in rfe.ranking_:\n",
    "    print(names[x-1], rfe.ranking_[x-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('gender', 0.093301587301587302)\n",
      "('age', 0.39391203703703703)\n",
      "('salary', 0.51278637566137575)\n"
     ]
    }
   ],
   "source": [
    "from sklearn.ensemble import RandomForestClassifier\n",
    "clf = RandomForestClassifier(n_estimators=10, random_state=123)\n",
    "\n",
    "clf.fit(X_val, y)\n",
    "\n",
    "names, clf.feature_importances_\n",
    "for feature in zip(names, clf.feature_importances_):\n",
    "    print(feature)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.09330159,  0.39391204,  0.51278638])"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf.feature_importances_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'Index' object cannot be interpreted as an integer",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-113-154ac3e37485>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnames\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m: 'Index' object cannot be interpreted as an integer"
     ]
    }
   ],
   "source": [
    "range(1, names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEKCAYAAADticXcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAE29JREFUeJzt3X+0XWV95/H3R2NUkBkVbgRJJBKqqFDKmLY0ooJxiBW0\n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54Lq8D3pnk\nW3QjjZlLE/8JXbB/E/hbuqkdjdengOf31/N/Ur/tzXRTZVvpzu2NwM7+T/TfBq5M8m3g9YtR8CPM\n8+m+u+EW4N3ARcBX6P6i+upu+n8YWJ/kFuCHs+20qh4AbgXu6QdaTfPaLyNKcgHd4/V7i12LxqcP\n8FP7K5CqEUkuBf5XVX10sWsZN0fqs0jyT5I8t19eDvwa8IXFrUoLLcmJSZ7YL/8y8AB+J0BTkhxB\n9zWbn17sWvYHXyid3aOBD6b7Hta/Ay6qqhsWuSYtvGOAzyYp4DbgX5Z/vjYjySuB9wK/UVV/t9j1\n7A9Ov0hSQ5x+kaSGGOqS1BBDXZIaYqhLUkMMdUlqyP8HCcjy0/nV46sAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xbde96d8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "plt.title('Feature Importance')\n",
    "plt.bar(range(0, len(names)), clf.feature_importances_)\n",
    "plt.xticks(range(0,len(names)), names)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
